home *** CD-ROM | disk | FTP | other *** search
/ Die Speccy' 97 / Die Speccy' 97.iso / amiga_system / the_aminet / comm / xeno / megacd.lha / megacd / MegaReq.rexx < prev    next >
OS/2 REXX Batch file  |  1995-10-01  |  15KB  |  577 lines

  1. /****************************************************************/
  2. /*                                                              */
  3. /*  MegaReq.rexx    v1.01 ⌐ David Huckett..                     */
  4. /*  Request Utility for MegaCD &  Xenolink.                     */
  5. /*   By David Huckett  23-Sep-95 3:640/800 Fido                 */
  6. /****************************************************************/
  7.  
  8.  
  9. /*  WARNING  CD-ROMs that have no name and show up on Workbench as Unnamed
  10. **           must only be used one at a time.. You can not have three volumes
  11. **           loaded in drives all called Unnamed.. It will confuse the door.
  12. */
  13.  
  14. MAXMARKED     = '5'
  15. ENFORCERATIOS = 'Y'
  16. REQPATH       = 'Doors:MegaCD/Requests/'
  17. BUFFERDIR     = 'Doors:MegaCD/BUFFER/' 
  18. CDCFG     = 'Doors:MegaCD/CD.cfg'
  19. SEARCHPATH= 'Doors:MegaCD/Search/'
  20.  
  21. VERS          = 'MegaReq v1.01'
  22. /****** EXTENSION REPLACEMENTS **********/
  23.  
  24. LHA = 'ED'x; DMS = 'E0'x; LZH = 'E1'x; TXT = 'E2'x; DOC = 'E3'x; MOD = 'E4'x
  25. ZIP = 'E5'x; ZOO = 'E6'x; ARC = 'E7'x; EXE = 'E8'x; LZX = 'E9'x; ARJ = 'EA'x
  26. GIF = 'EB'x; TIF = 'EC'x; BMP = 'EE'x; JPG = 'EF'x; PCX = 'F0'x
  27.  
  28. options results
  29.  
  30. SysopLog 'Entered Door: MegaReq.'
  31.  
  32. PR = 'PRINT'
  33.  
  34. arg Node_Number CDName ConfigCd
  35. host = 'XenolinkRexxPort'Node_Number
  36. address value host
  37. signal on error
  38. signal on syntax
  39. signal on IOERR
  40.  
  41.  if ~show('L','rexxsupport.library') then do
  42.   if ~addlib('rexxsupport.library',0,-30,0) then do
  43.     PR 'Support library not available.'
  44.      call error
  45.     signal Quit
  46.    end
  47. end
  48.  
  49. getuservar name ; nicename strip(result); name = result
  50. getuservar privilege ; access = result
  51.  
  52. getuservar fileratio ; fileratio = result
  53. getuservar uploads   ; uploads   = result
  54. getuservar downloads ; downloads = result
  55.  
  56. If Downloads = 0 & Uploads = 0 Then Uploads = 1
  57.  
  58.     If FileRatio = 0 Then do
  59.         ActFileRatio = 'Unlim'
  60.     end
  61.     else ActfileRatio = FileRatio
  62.  
  63. If EnforceRatios = 'Y' Then do
  64.    If FileRatio ~= 0 Then do
  65.       NumRemain = (Uploads * FileRatio) - Downloads
  66.         If Numremain < 1 Then NumRemain = 0
  67.    End
  68.  
  69.    If NumRemain <1 Then Signal Ratio
  70. IF MaxMarked > Numremain Then MaxMarked = NumRemain
  71. End
  72.  
  73.  
  74. fullname = SPACE(name,1,_)
  75.  
  76. GETUSERVAR MENUSET 
  77. gfx=result         
  78. if gfx >='1' then do
  79.     WHI='';RED='';GRN='';BGRN='';YEL='';BYEL='';BLU='';MAJ='';CYA='';BCYA='';OFF=''
  80. END
  81.     ELSE DO
  82.     WHI='';RED='';GRN='';BGRN='';YEL='';BYEL='';BLU='';MAJ='';CYA='';OFF='';BCYA=''
  83. END
  84.  
  85.  
  86. START:
  87. CLS
  88. pr BLU'                ┌───────────────────────────────────┐'
  89. pr '                │'BGRN'  Offline CD-Rom Request Utility'OFF||BLU'   │'
  90. pr BLU'                │                                   │'
  91. pr BLU'                │'BCYA'          'VERS||OFF||BLU'            │'
  92. pr BLU'                │'BCYA'   by David Huckett 16-Sep-95..'OFF||BLU'    │'
  93. pr BLU'                └───────────────────────────────────┘'OFF
  94. pr
  95. pr '                     ('GRN'R'OFF') Request a file.'
  96. pr '                     ('GRN'K'OFF') Delete your request.'
  97. pr '                     ('GRN'V'OFF') View your requests.'
  98. pr '                     ('GRN'D'OFF') Download Waiting Files.'
  99. pr '                     ('GRN'A'OFF') About MegaREQ.'
  100. pr '                     ('RED'Q'OFF') Quit.'
  101. pr
  102.  
  103. prompt 20 normal BYEL' Make your selection > 'OFF
  104. cmd=strip(upper(result))
  105.  
  106. SELECT
  107.         when cmd  =  'A' then signal About
  108.         when cmd  =  ''  then signal start
  109.         when cmd  =  'V' then signal View
  110.                 when cmd  =  'K' then signal DelReq
  111.                 when cmd  =  'D' then signal Download
  112.         when cmd  =  'R' then signal Request
  113.         when cmd  =  "###PANIC" then call Quit
  114.                 when left(cmd,1)='Q' then signal quit
  115.  
  116. OTHERWISE
  117.         pr
  118.                 pr 'Unkown Command 'cmd
  119.         call delay 50
  120. signal start
  121.  
  122.  
  123.  
  124. DOWNLOAD:
  125. if ~exists(REQPATH||Fullname'.fnd') then do
  126. pr
  127. pr 'There are no buffered requests waiting for you to download..'
  128. call delay 100
  129. signal start
  130. end
  131.     if ~exists('T:MRXDL'node_Number'.sfl') Then call open(tempdl,'T:MRXDL'node_Number'.sfl','W')
  132.     else Call open(Tempdl,'T:MRXDL'node_Number'.sfl','A')
  133.  
  134.     Call open(rfile,REQPATH||FULLNAME'.fnd',R)
  135.     Do i = 1 Until EOF(rfile)
  136.         FILENAME.i = strip(Readln(rfile))
  137.     if filename.i = '' then leave i
  138.     Call WriteLn(Tempdl,BUFFERDIR  FILENAME.i)
  139.     end
  140.  
  141.     Call close(Tempdl)
  142.     Call close(rfile)
  143.  
  144.         address command 'DELETE 'REQPATH||FULLNAME'.fnd QUIET'
  145. pr
  146. pr ' You may now use MegaRXDL to download your requested files...'
  147. pr ' When you have exited MegaCD, please use the download command normally'
  148. pr ' used to download files from the CD's.... '
  149. pr
  150. msg 'Any key to continue..'
  151. Getchar
  152.  
  153. exit 0
  154.  
  155.  
  156. /***************** View Requests *******************/
  157.  
  158. VIEW:
  159.  
  160. If ~EXISTS(REQPATH||FULLNAME'.req') Then Do
  161. pr
  162. pr ' No saved file requests found....'
  163. call delay 100
  164. signal START
  165. END
  166. Else do
  167. CLS
  168. PR
  169.     Call open(rfile,REQPATH||FULLNAME'.req',R)
  170.     Do i = 1 UNTIL EOF(rfile)
  171.     rquest.i = strip(readln(rfile))
  172.         if rquest.i = '' then do
  173.             i=i-1
  174.             iterate
  175.             end
  176.     pr left(' 'i'.',4)||left(word(rquest.i,4),25)'Requested on: 'word(rquest.i,1)
  177. end
  178. call close(rfile)
  179. pr
  180. msg 'Hit any key to continue..'
  181. getchar
  182. signal start
  183.  
  184.  
  185.  
  186.  
  187. /**************** Delete requests *****************/
  188.  
  189. DELREQ:
  190.  
  191. If ~EXISTS(REQPATH||FULLNAME'.req') Then Do
  192. pr
  193. pr ' No saved file requests found....'
  194. call delay 100
  195. signal START
  196. END
  197. Else do
  198. CLS
  199. PR
  200.     Call open(rfile,REQPATH||FULLNAME'.req',R)
  201.     Do i = 1 UNTIL EOF(rfile)
  202.     rquest.i = strip(readln(rfile))
  203.         if rquest.i = '' then do
  204.             i=i-1
  205.             iterate
  206.             end
  207.     pr left(' 'i'.',4)||left(word(rquest.i,4),25)'Requested on: 'word(rquest.i,1)
  208. end
  209. call close(rfile)
  210. numreqs = i
  211. pr
  212. pr YEL'Enter the number of the request to delete,'
  213. prompt 4 normal YEL'ALL to delete all, or  hit <return> to abort.. '
  214.  
  215. ans = strip(upper(result))
  216.  
  217. if ans = '' then signal start
  218. if ans = 'ALL' then do
  219.  
  220.     call open(delfile,REQPATH||FULLNAME'.req', 'R')
  221.         do i = 1 until EOF(delfile)
  222.         kill.i = word(readln(delfile),4)
  223.         if kill.i = '' then iterate
  224.         if exists(BUFFERDIR||Kill.i) then do
  225.             killcmd = 'DELETE 'BUFFERDIR||Kill.i' QUIET'
  226.             address command killcmd
  227.             end
  228.         end
  229.         call close(delfile)
  230.     address command 'DELETE 'REQPATH||FULLNAME'.req QUIET'
  231. if exists(REQPATH||FULLNAME'.fnd') then address command 'DELETE 'REQPATH||FULLNAME'.fnd QUIET'
  232.     pr 'ALL Requests deleted...'
  233.     call delay 100
  234.     signal start
  235. end
  236.  
  237. if Datatype(ans, 'N') = 1 then do
  238. if ans<= i then call DELETE(ans)
  239. else pr RED'You dont have that many requests.'OFF
  240. call delay 100
  241. signal start
  242. end
  243.  
  244. pr ' Unknown command: 'ans
  245. msg 'Hit any key'
  246. getchar
  247. signal start
  248.  
  249.  
  250. DELETE:
  251. PARSE ARG line
  252. filetokill = word(rquest.line,4)
  253.     Call open(rfile,REQPATH||FULLNAME'.req',w)
  254.     Do i = 1 to numreqs-1
  255.     if line = i then iterate i
  256.     call writeln(rfile,rquest.i)
  257.     end
  258. call close(rfile)
  259.  
  260.     if exists(BUFFERDIR||filetokill) then do
  261.             killcmd = 'DELETE 'BUFFERDIR||filetokill' QUIET'
  262.             address command killcmd
  263.             end
  264.  
  265. pr
  266. pr CYA||FileToKill||RED' deleted!'OFF
  267. pr
  268. msg 'Any key to continue..'
  269. getchar
  270. signal start
  271.  
  272.  
  273. /**************** REQUEST FILES *******************/
  274.  
  275. REQUEST:
  276. i=0
  277. if exists(REQPATH||FULLNAME'.req') then do
  278.     Call open(rfile,REQPATH||FULLNAME'.req',R)
  279.     Do i = 1 UNTIL EOF(rfile)
  280.     Junk.i = readln(rfile)
  281.         if Junk.i = '' then do
  282.             i=i-1
  283.             iterate
  284.             end
  285. end
  286. call close(rfile)
  287. end
  288. numreqs = i
  289.  
  290. if NUMREQS >= MAXMARKED then do
  291. pr
  292. pr 'You have the maximum ('GRN||MAXMARKED||OFF') requests pending on you account..'
  293. pr 'Some requests may have been filled, so delete any of these filled'
  294. pr 'requests first, or remove any unwanted requests from your list to'
  295. pr 'enable further new requests..'
  296. pr 'If you believe there may be a problem (bugs may exist) contact'
  297. pr 'the sysop....'
  298. pr
  299. msg 'Any key to continue..'
  300. getchar
  301. signal start
  302. end 
  303.  
  304.  
  305.  
  306. FileName = ''
  307. Directory = ''
  308.  
  309. CLS
  310. pr
  311. pr BLU'       ┌─────────────────────────────────────────────────┐'
  312. pr '       │                                                 │'
  313. pr '       │'GRN'             Date: 'CYA||left(Date(),30)||BLU'│'
  314. pr '       │                                                 │'
  315. pr '       │'GRN'     Requested by: 'CYA||left(Name,30)||BLU'│'
  316. pr '       │                                                 │'
  317. pr '       │'GRN'   File Requested:'BLU'                               │'
  318. pr '       │                                                 │'
  319. pr '       │'GRN'           CD-Rom: 'CYA||left(cdname,15)||BLU'               │'
  320. pr '       │                                                 │'
  321. pr '       └─────────────────────────────────────────────────┘'OFF
  322. pr
  323. pr
  324.  
  325. GetFileName:
  326.  
  327. Getline 30 Normal YEL' Enter the requested filename: 'OFF
  328. Filename = Strip(Result)
  329. if filename = '' then signal start
  330. msg BYEL "8H"Left(FileName,30)"1H"
  331.  
  332. /************* Request Prompt ************/
  333.  
  334. RPROMPT:
  335. do until ans = ''
  336. msg GRN"1H ('OFF'A'GRN') Change Filename. ('OFF'B'GRN') Cancel Request.."OFF
  337. msg GRN"1H If all acceptable hit <'OFF'return'GRN'>.1H"OFF
  338.  
  339. Getline 30 Normal YEL' ('OFF'A'YEL'),('OFF'B'YEL'),<'OFF'return'YEL'>: 'OFF
  340. answer = Strip(Upper(Result))
  341.  
  342. msg '1H1H1H'
  343.  
  344.  
  345.  SELECT
  346.         WHEN answer = 'A' then call GetFileName
  347.         WHEN answer = 'B' then Call Cancel
  348.         WHEN answer = '' then break
  349.         OTHERWISE NOP
  350.  END
  351. end
  352.  
  353. if Filename = '' then do
  354. cls
  355. pr
  356. pr RED' No file requested'OFF
  357. end
  358. else signal savefilereq
  359.  
  360. Signal Start
  361.  
  362.  
  363. /**************** SaveFileRequest *****************/
  364.  
  365. SAVEFILEREQ:
  366. cls
  367. pr
  368. msg GRN' Saving request.'OFF
  369.  
  370. find1 = strip(Filename)
  371. find = upper(find1)
  372. noExt = 0
  373. extens = right(find,4)
  374.             SELECT
  375.  
  376.     When extens = '.LHA' then find = left(find,(length(find)-4))||upper(LHA)
  377.     When extens = '.ZIP' then find = left(find,(length(find)-4))||upper(ZIP)
  378.     When extens = '.DMS' then find = left(find,(length(find)-4))||upper(DMS)
  379.     When extens = '.MOD' then find = left(find,(length(find)-4))||upper(MOD)
  380.     When extens = '.LZH' then find = left(find,(length(find)-4))||upper(LZH)
  381.     When extens = '.TXT' then find = left(find,(length(find)-4))||upper(TXT)
  382.     When extens = '.EXE' then find = left(find,(length(find)-4))||upper(EXE)
  383.     When extens = '.JPG' then find = left(find,(length(find)-4))||upper(JPG)
  384.     When extens = '.GIF' then find = left(find,(length(find)-4))||upper(GIF)
  385.  
  386.             OTHERWISE NoExt = 1
  387. end
  388.  
  389. IndTIT = CDName
  390. If ~exists(SearchPath||IndTIT||'.dex') then do
  391. pr
  392. pr 'Cant find a Search index file for this CD-Rom...'
  393. pr 'Ask the sysop to create one so Requests can be made from that CD-Rom...'
  394. msg 'Any key to continue...'
  395. getchar
  396. Exit 0
  397. end
  398. fnd = 0
  399. if NoExt = 0 then find = left(find,(length(find)-1))
  400. c = 0
  401. call open(fllist,SearchPath||IndTIT||'.dex','R')
  402.     Findpath = Readln(fllist)
  403.     do l =1 until EOF(fllist)
  404. c = c+1
  405. if c = 4 then do
  406. msg '.'
  407. c= 0
  408. end
  409.     findln.l = Readln(fllist)
  410.     findln.l = Upper(findln.l)
  411.     t= index(findln.l,find)
  412.     if t ~= 0 then do
  413.  
  414.         configCD = strip(configCD)
  415.         call open(ccfg,configCD, 'R')
  416.         cdpathname  = readln(ccfg)
  417.         indexpath   = readln(ccfg)
  418.         displayfile = readln(ccfg)
  419.         skipstart   = readln(ccfg)
  420.  
  421.         do j = 1 to word(findln.l,1)
  422.         directory    = word(readln(ccfg),1)
  423.         end
  424.         call close(ccfg)
  425. fnd = 1
  426. pr 'Done!'
  427. leave l
  428. end
  429. end
  430. call close(fllist)
  431.  
  432. if fnd ~= 0 then signal FOUND
  433.  
  434. pr
  435. pr CYA'File not found on this CD.. Was spelling correct?'OFF
  436. getchar
  437. Exit 0
  438.  
  439.  
  440.  
  441. FOUND:
  442. PathFile = left(Indexpath||directory,50)
  443.  
  444. day = left(space(date(),1,_),15)
  445. username = Left(FullName,30)
  446. fle      = left(Find1,25)
  447.  
  448.  
  449. If ~EXISTS(REQPATH||FULLNAME'.req') THEN Call Open(rfile,REQPATH||FULLNAME'.req',W)
  450. else Call Open(rfile,REQPATH||FULLNAME'.req',A)
  451. Call writeln(rfile,day||username||Pathfile||fle)
  452. Call close(rfile)
  453.  
  454. If ~EXISTS(REQPATH||CDNAME'.req') THEN Call Open(cfile,REQPATH||CDNAME'.req',W)
  455. else Call Open(cfile,REQPATH||CDNAME'.req',A)
  456. Call writeln(cfile,username||Pathfile||fle)
  457. Call close(cfile)
  458.  
  459.  
  460. Signal start
  461.  
  462.  
  463.  
  464. /**************** Cancel **************************/
  465.  
  466. CANCEL:
  467.  
  468. FILENAME = ''
  469. msg BYEL "8H"Left(FileName,30)"1H"
  470. msg BYEL "28H"Left(CDNAME,30)"1H"
  471.  
  472. Return
  473.  
  474. /**************** ABOUT ***************************/
  475.  
  476. ABOUT:
  477.  
  478. CLS
  479. pr
  480. pr GRN'                           ABOUT MegaREQ'OFF
  481. pr YEL'                          -----------------'OFF
  482. pr
  483. pr CYA'            Program Name:'OFF' MegaReq  Offline CD-Rom File Request'
  484. pr CYA'                   Short:'OFF' MegaReq'
  485. pr CYA'                Language:'OFF' Amiga Arexx'
  486. pr CYA'              Written By:'OFF' David Huckett'
  487. pr CYA'                    Date:'OFF' 16-Sep-95'
  488. pr CYA'             Description:'OFF' This program is used to allow users to be'
  489. pr CYA'                          able to request files that exist on'
  490. pr '                          available CD-Rom disks which are currently'
  491. pr '                          NOT ONLINE..'
  492. pr '                          It recieves the request, and next time the CD'
  493. pr '                          that contains the file is loaded, part two of'
  494. pr '                          this program automatically copies the'
  495. pr '                          requested file(s) to system hard drives and'
  496. pr '                          either upon your next login, you will be'
  497. pr '                          notified thay are waiting, or you may'
  498. pr '                          check for waiting files from within this'
  499. pr '                          Door..'
  500. pr
  501. msg ' Any key to continue '
  502. getchar
  503. signal start
  504.  
  505. /**************** RATIO handling ******************/
  506.  
  507. RATIO:
  508.  
  509. Pr
  510. Pr ' Sorry, but it appears you have no download file credits to enable'
  511. Pr '        the use of this Request door..  You must upload some files'
  512. Pr '        to the system to gain enough credits to use this facility..'
  513. Pr
  514. Pr ' Any confusions on the use of this program may be explained by'
  515. Pr '        hitting (A) now for a breif explanation, or you may contact'
  516. Pr '        the Sysop for any further help..'
  517. Pr
  518. prompt 2 normal ' <return> to continue (A)bout. '
  519. key = upper(Result)
  520.     if key = 'A' then do
  521. CLS
  522. pr
  523. pr
  524. pr '              MegaReq OFFLINE CD File Request...'
  525. pr
  526. pr '   SHORT:'
  527. pr '           This program allows users to specify up to five(5) files'
  528. pr ' that exist on system CD-Rom disks, presently not loaded in a drive.'
  529. pr
  530. pr ' Each time a different CD disk is loaded in system drive bays,'
  531. pr ' the system will process the names of files and if possible, any'
  532. pr ' directory path specified, in an attempt to locate your requested'
  533. pr ' files..'
  534. pr
  535. pr ' Should your requested file be located, it will be copied across to'
  536. pr ' a buffer directory, and the next time you call and the CD that contains'
  537. pr ' the file(s) you requested has been loaded, you will be notified that'
  538. pr ' your requested files are waiting..  You may then add them to your'
  539. pr ' download list or enter MegaCD and the request area to add them at a'
  540. pr ' later time..'
  541. pr
  542. pr ' Please note, it is advisable to first download the CD-Rom file lists'
  543. pr ' from within MegaCD Door, and choose the correct filenames..'
  544. pr
  545. Msg ' Any key to exit. '
  546. getchar
  547. end
  548.  
  549. Signal Quit
  550.  
  551. /**************** QUIT from door ******************/
  552.  
  553. QUIT:
  554.  
  555. SysopLog 'Exited MegaReq Door (return code 0)'
  556. exit 0
  557.  
  558.  
  559. /*************** ERROR Routine *******************/
  560. error:
  561. a = SIGL;message 'Error!!!  Line # 'a;call delay 200
  562. SysopLog 'ERROR MegaReq line # 'a
  563.  
  564.  
  565. EXIT 10
  566.  
  567. syntax:
  568. a = SIGL;message 'Syntax Error!!!  Line # 'a;call delay 200
  569. SysopLog 'SYNTAX ERROR MegaReq line # 'a
  570. EXIT 10
  571.  
  572. ioerr:
  573. message 'I/O Error!!!';call delay 200
  574. SysopLog 'IO ERROR MegaReq.'
  575.  
  576. EXIT 10
  577.